//
//  NetworkTools.h
//  OCMicroBlog
//
//  Created by 002 on 15/11/4.
//  Copyright © 2015年 002. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AFNetworking/AFNetworking.h>

/**
 网络请求枚举类型
 */
typedef enum : NSUInteger {
    GET,
    POST
}HFHRequsetMethod;

typedef void (^RequestCallBack) (id result,NSError *error);

@protocol NetworkToolsProxy <NSObject>

/**
 *  AFN内部网络请求方法
 *
 *  @param method     请求方法
 *  @param URLString  请求地址
 *  @param parameters 请求参数
 *  @param success    成功回调
 *  @param failure    失败回调
 *
 *  @return NSURLSessionDataTask 需要 resume
 */
@optional
- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method
     URLString:(NSString *)URLString
    parameters:(id)parameters
       success:(void (^)(NSURLSessionDataTask *, id))success
       failure:(void (^)(NSURLSessionDataTask *, NSError *))failure;

@end

/**
 *  网络工具类
 */
@interface NetworkTools : AFHTTPSessionManager

// OAuth 相关方法和属性
@property(nonatomic,strong) NSURL *oauthUrl;

// 网络工具单例接口
+(instancetype)sharedTools;

// 网络请求方法
- (void)request:(HFHRequsetMethod)method URLString:(NSString *)URLString parameters:(id)parameters finished:(void (^)(id retuslt,NSError *error))finished;

// 加载 accessToken
- (void)loadAccessTokenWithCode:(NSString *)code finished:(RequestCallBack)finished;

// 加载用户信息
- (void)loadUserInfoWithUID:(NSString *)uid finished:(RequestCallBack)finished;

// 加载微博数据
- (void)loadStatus:(NSUInteger) since_id max_id:(NSUInteger)max_id finished:(RequestCallBack)finished;

@end
